#coding: utf-8 or # -*- coding: utf-8 -*-
# 导入:
from sqlalchemy import Column, String, create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from json import decoder , encoder ,dumps,loads

<<<<<<< .mine
=======

>>>>>>> .r7
# 初始化数据库连接:create_engine()用来初始化数据库连接。SQLAlchemy用一个字符串表示连接信息：
engine = create_engine('oracle://card_vip:111111@192.168.1.3:1521/orcl')
# 创建DBSession类型:
DBSession = sessionmaker(bind=engine)
# print engine
# print DBSession
session = DBSession()

# print session
<<<<<<< .mine

=======
>>>>>>> .r7
# 创建对象的基类:
Base = declarative_base()

# 定义User对象:
class infor_gather(Base):
    # 表的名字:
    __tablename__ = 'infor_gather'
    # 表的结构:
    c_gather_id = Column(String(20), primary_key=True)
    c_gather_name = Column(String(20))


# filter(infor_gather.c_gather_id=='00')
infor_gather = session.query(infor_gather.c_gather_id).all()
# 打印类型和对象的name属性:
for info in infor_gather:
	print type(info.c_gather_id)
	print info.c_gather_id
	
# print infor_gather.c_gather_id

print type(infor_gather)
#dumps(infor_gather)

# 关闭Session:
session.close()

# # 创建session对象:
# session = DBSession()
# # 创建新User对象:
# new_user = User(id='5', name='Bob')
# # 添加到session:
# session.add(new_user)
# # 提交即保存到数据库:
# session.commit()
# # 关闭session:
# session.close


